package im.yisme.view.ui.animation;

import android.os.Handler;
import android.os.Message;

public class BGP extends Thread{

	private boolean isRunning;
	private int index;
	private Handler bgpHandler;
	private static final int NUM_OF_BGP=5;
	private static final int BGP_UPDATE_INTERVAL=100;
	
	public BGP(Handler bgpHandler){
		this.bgpHandler = bgpHandler;
		isRunning = true;
		index = 0;
	}
	public void run(){
	
		while(isRunning){
			
			index = (index+1)%NUM_OF_BGP;
			
			Message m = new Message();
			m.what = index;
		    bgpHandler.sendMessage(m);
			
		    try {
				Thread.sleep(BGP_UPDATE_INTERVAL);
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
	}
	public void stopRunning(){
		isRunning = false;
	}
}
